import React from "react";
import { HashRouter, Switch } from "react-router-dom";
import Index from "./pages/index/index";
import Clock from "./pages/clock/clock";
import Me from "./pages/me/index";
import Learn from "./pages/learn/index";
import ClockDate from "./pages/clock/date";
import Show from "./pages/show";
import Invite from "./pages/me/invite";
import Recommend from "./pages/me/recommend";
import Meclock from "./pages/clock/index";
import Melearn from "./pages/me/learn";
import Rank from "./pages/rank";
import Topic from "./pages/learn/topic";
import Course from "./pages/learn/course";
import Help from "./pages/help";
import Integral from "./pages/me/integral";
import Progress from "./pages/progress";
import Search from "./pages/search";

// 权限控制高级组件
import AuthComponent from "./components/common/authComponent";

export const routerConfig = [
  {
      path:'/',
      component:Index,
      auth: true
  },
  {
      path:'/search/:keywords',
      component:Search,
  },
  {
      path:'/clock',
      component:Clock,
      auth: 'activated'
  },
  {
      path:'/clockDate/:id',
      component:ClockDate,
      auth: 'activated'
  },
  {
      path:'/show/:id',
      component:Show
  },
  {
      path:'/progress/:id',
      component:Progress,
      auth: 'studed'
  },
  {
      path:'/me',
      component:Me,
      auth:false,
  },
  {
      path:'/meclock/:id',
      component:Meclock,
      auth: 'activated'
  },
  {
      path:'/melearn',
      component:Melearn
  },
  {
      path:'/integral',
      component:Integral
  },
  {
      path:'/rank/:id',
      component:Rank
  },
  {
      path:'/invite',
      component:Invite
  },
  {
      path:'/recommend',
      component:Recommend
  },
  {
      path:'/learn',
      component:Learn,
      auth: 'studed'
  },
  {
      path:'/course/:id',
      component:Course,
      auth: 'studed'
  },
  {
      path:'/topic/:sid/:cid',
      component:Topic,
      auth: 'worked'
  },
  {
      path:'/help',
      component:Help
  },
  {
      path:'*',
      component:Index
  }
];

export default () => {
  return (
    <div>
      <HashRouter>
        <Switch>
          <AuthComponent config={routerConfig} />
        </Switch>
      </HashRouter>
    </div>
  );
};
